package com.compass.doctor.ui.home.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutOrderLogItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.ext.gone
import com.compass.framework.ext.visible
import com.compass.framework.model.Log
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 订单进度日志
 * Date:2024/1/15 15:24
 */
class OrderLogAdapter : BaseRecyclerViewAdapter<Log, LayoutOrderLogItemBinding>() {
    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutOrderLogItemBinding>,
        item: Log?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvTitle.text =item.stepText

            item.describe?.let {
                tvHospital.text="$it ${DateUtils.conversionTime(item.createTime,DateUtils.FORMAT_TWO)}"
            }?:kotlin.run {
                tvHospital.text=DateUtils.conversionTime(item.createTime,DateUtils.FORMAT_TWO)
            }

            if (position==getData().size-1){
                ivTip.background= getDrawableResource(R.drawable.bg_order_log_ing)
                dvLine.gone()
            }else{
                ivTip.background= getDrawableResource(R.drawable.bg_order_log_over)
                dvLine.visible()
            }

        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutOrderLogItemBinding {
        return LayoutOrderLogItemBinding.inflate(layoutInflater, parent, false)
    }
}